package common.service;

import java.util.List;
import java.util.Map;

import net.sf.json.JSONObject;

import common.serialization.IWebText;
import common.splitpage.PageInfo;
import common.transaction.IServiceTransaction;
import common.transaction.TransactionAnnotation;
import common.transaction.TransactionAnnotation.TransactionType;
import common.web.WebHelper;

public interface IService extends IServiceTransaction {
	
	//设置web信息
	void setWebHelper(WebHelper webHelper);
	
	//保存数据
	@TransactionAnnotation(transactionType = TransactionType.UPDATE)
	public IWebText save(JSONObject json) throws Exception;
	
	//删除数据
	@TransactionAnnotation(transactionType = TransactionType.UPDATE)
	public IWebText del(JSONObject json) throws Exception ;
	
	//根据sql语句更新数据
	@TransactionAnnotation(transactionType = TransactionType.UPDATE)
	public int executeBySql(String sql) throws Exception ;
	
	@TransactionAnnotation(transactionType = TransactionType.UPDATE)
	public int executeBySql(String sql,Object[] parameters) throws Exception ;
	
	//根据sql语句更新数据
	@TransactionAnnotation(transactionType = TransactionType.UPDATE)
	public int[] executeBySql(String[] sqlArr) throws Exception ;
	
	//根据sql语句批量更新数据
	@TransactionAnnotation(transactionType = TransactionType.UPDATE)
	public int[] executeBatchBySql(String sql, List<Object[]> parameterList) throws Exception ;
	
	//获取xml数据
	@TransactionAnnotation
	public IWebText getXmlDataBySql(String sql, String pkName) throws Exception ;
	
	//获取json数据
	@TransactionAnnotation
	public IWebText getJsonDataBySql(String sql) throws Exception ;
	
	//获取分页数据
	@TransactionAnnotation
	public PageInfo getPageInfo(PageInfo pageInfo) throws Exception ;
	
	//计算记录数，用于分页
	@TransactionAnnotation
	public int count(String sql) throws Exception ;
	
	//根据sql查询数据
	@TransactionAnnotation
	public List<Map<String,Object>> queryBySql(String sql) throws Exception ;
	
	//根据sql查询数据
	@TransactionAnnotation
	public List<Map<String,Object>> queryBySql(String sql, Object[] parameters) throws Exception ;
	
	//根据ID查询数据
	@TransactionAnnotation
	public Map<String,Object> queryById(String sql) throws Exception ;
	
	//根据ID查询数据
	@TransactionAnnotation
	public Map<String,Object> queryById(String sql, Object[] parameters) throws Exception ;
	
	//获取分页数据,用于分页列表页面
	@TransactionAnnotation
	public PageInfo getPageInfo() throws Exception ;
	
	//获取列表的所有数据
	@TransactionAnnotation
	public List<Map<String,Object>> getListData() throws Exception ;
	
	//根据ID获取数据,用于编辑页面
	@TransactionAnnotation
	public Map<String,Object> getEntityData() throws Exception ;
	
	//保存
	@TransactionAnnotation(transactionType = TransactionType.UPDATE)
	public Map<String,Object> save() throws Exception  ;
	
	//保存
	@TransactionAnnotation(transactionType = TransactionType.UPDATE)
	public Map<String,Object> save(Map<String,Object> map, String tableName) throws Exception ;
		
	//保存树型数据
	@TransactionAnnotation(transactionType = TransactionType.UPDATE)
	public void saveTreeData() throws Exception ;
	
	//根据数据字典翻译数据
	public void parseDD(List<Map<String, Object>> dataList, List<Map<String,Object>> configList) throws Exception ;
	
	//根据数据字典翻译数据
	public void parseDD(List<Map<String, Object>> dataList, String tableName) throws Exception ;
	
	//根据数据字典翻译数据
	public void parseDD(Map<String, Object> map, List<Map<String,Object>> configList) throws Exception ;
	
	//根据数据字典翻译数据
	public void parseDD(Map<String, Object> map, String tableName) throws Exception ;
	
	//设置数据字典
	public void setDD(Map<String,Object> entity, List<Map<String,Object>> configList) throws Exception ;
	
	//设置搜索条件
	public String getCondition(List<Map<String,Object>> configList) ;
	
	public void setButtonMap(String tableName) throws Exception ;
	
	public String getSqlByType(String fieldType, String fieldName, String value, Boolean isInsert) ;
	
	//从配置信息中获取主键字段名
	public String getPkName(List<Map<String,Object>> configList) ;
	
}
